home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / Transition.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  1.9 KB  |  76 lines

  1. class Transition extends State
  2. {
  3.    var bIsLeft;
  4.    var sGoingTo;
  5.    var classToMove;
  6.    var sState;
  7.    var mcRef;
  8.    static var sEXCEPTION = "Instructions";
  9.    static var sSTATE_IDLE = "Idle";
  10.    static var sSTATE_PLAY_LEFT = "PlayLeft";
  11.    static var sSTATE_PLAY_RIGHT = "PlayRight";
  12.    static var nFRAME_CHANGE = 30;
  13.    function Transition(_mcRef)
  14.    {
  15.       super(_mcRef,false);
  16.       this.setState(Transition.sSTATE_IDLE);
  17.       this.bIsLeft = !!Math.round(Math.random());
  18.    }
  19.    function goTo(_sGoingTo, _classToMove)
  20.    {
  21.       this.sGoingTo = _sGoingTo;
  22.       if(!(_classToMove instanceof State) || (_classToMove == undefined || _classToMove == null))
  23.       {
  24.          this.classToMove = Main.getRef();
  25.       }
  26.       else
  27.       {
  28.          this.classToMove = _classToMove;
  29.       }
  30.       if(this.sState == Transition.sSTATE_IDLE)
  31.       {
  32.          if(this.bIsLeft)
  33.          {
  34.             this.setState(Transition.sSTATE_PLAY_RIGHT);
  35.             this.bIsLeft = false;
  36.          }
  37.          else
  38.          {
  39.             this.setState(Transition.sSTATE_PLAY_LEFT);
  40.             this.bIsLeft = true;
  41.          }
  42.       }
  43.       Controller.getRef().getSounds().playSound("SFX_Transition",Controller.nSFX_VOLUME,1);
  44.    }
  45.    function managePlayAnim()
  46.    {
  47.       if(this.stateFinished())
  48.       {
  49.          this.setState(Transition.sSTATE_IDLE);
  50.       }
  51.       else if(this.mcRef.mcState._currentframe == Transition.nFRAME_CHANGE)
  52.       {
  53.          if(this.sGoingTo != Transition.sEXCEPTION)
  54.          {
  55.             Controller.getRef().getInstructions().doHide();
  56.             this.classToMove.setState(this.sGoingTo);
  57.          }
  58.          else
  59.          {
  60.             Controller.getRef().getInstructions().doShow();
  61.          }
  62.       }
  63.    }
  64.    function Idle()
  65.    {
  66.    }
  67.    function PlayLeft()
  68.    {
  69.       this.managePlayAnim();
  70.    }
  71.    function PlayRight()
  72.    {
  73.       this.managePlayAnim();
  74.    }
  75. }
  76.